package com.backend.demo.action;

import java.util.Map;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

@ParentPackage("user")
@Namespace("/jspView")
@InterceptorRefs(value = { @InterceptorRef(value = "loginStack") })
@Controller
public class ChangeLanguageAction extends ActionSupport implements RequestAware,SessionAware {
	
	private static final long serialVersionUID = 1L;
	
	private Map<String,Object> request;
	
	private Map<String,Object> session;
	@Action(value="change",results={@Result(name=SUCCESS,location="/jspView/index.jsp"),@Result(name=ERROR,location="/jspView/login.jsp")})
	public String execute(){
		String language = ServletActionContext.getRequest().getParameter("request_locale");
		session.put("language", language);
		return SUCCESS;
	}

	@Override
	public void setRequest(Map<String, Object> request) {
		this.request = request;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

}
